<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 200px;
            height: 200px;
            border: 1px solid #09f;
            box-shadow: 2px 2px 1px #666;
            position: absolute;
        }
    </style>
</head>
<body>
    <input type="button" value="弹窗">
    <script>
 
  function Singleton(name) {
    this.name = name;
    
    this.instance = null; 
  }
  
  Singleton.prototype.say = function() {
    console.log('说点什么');
  }
 
  Singleton.getInstance = function(name) {
   
  }
  

  
        //很多人不登陆的 先不加载登录框，性能更好
        let offset = 20 ,index = 1;
        function Modal(pos){
            this.offset = pos || 20
            this.instance = null;
        }
        Modal.prototype.create = function(){
            const oDiv = document.createElement('div');
            oDiv.style.left = (++index) * this.offset +'px';
            oDiv.style.top = (++index) * this.offset +'px';
            oDiv.innerHTML = index
            
            if (!this.instance) {
            this.instance = new Modal(pos)
            }
            return this.instance;
            return oDiv
        }
        const oBtn = document.querySelector("input");
        oBtn.addEventListener('click',function(){
            //动态加载

            let model = new Modal();
            document.body.appendChild(model.create());
                        },false)
    </script>
</body>
</html>